package dataPool;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * 线程池的连接，包含属性是否被占用
 * Created by Administrator on 2018/6/11.
 */
public class PoolConnnection {
    /**
     * 是否被占用
     * */
    boolean isBusy;
    Connection connection;

    public boolean isBusy() {
        return isBusy;
    }

    public void setBusy(boolean busy) {
        isBusy = busy;
    }

    public Connection getConnection() {
        return connection;
    }

    public void setConnection(Connection connection) {
        this.connection = connection;
    }

    public PoolConnnection(Connection connection,boolean isBusy){
        this.connection = connection;
        this.isBusy= isBusy;
    }
    //释放
    public void close(){
        this.isBusy = false;    
    }
    //执行sql
    public ResultSet queryBysql(String sql){
        Statement sm = null;
        ResultSet rs = null;
        try {
           sm =  connection.createStatement();
           rs = sm.executeQuery(sql);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return rs;
    }
}
